package wsz.util;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

/**
 * @author wsz
 * @date 2021/12/27 11:39
 **/
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class CommonResult {
    private String code;
    private Object data;
    private String msg;

    public boolean isOk() {
        return "200".equals(this.code);
    }

    public static CommonResult getDefaultError() {
        return new CommonResult("502", null, "error");
    }
    public static CommonResult initError(Object data, String msg) {
        return new CommonResult("502", data, msg);
    }

    public static CommonResult getDefault(Object data) {
        return new CommonResult("200", data, null);
    }

    public static CommonResult getSuccess() {
        return new CommonResult("200", null, null);
    }

    public static CommonResult getDefault(Object data, String msg) {
        return new CommonResult("200", data, msg);
    }

    public static CommonResult getInit(String code, Object data, String msg) {
        return new CommonResult(code, data, msg);
    }
}
